home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / FinderFlocks / CBoid.h < prev    next >
C/C++ Source or Header  |  1996-06-23  |  1KB  |  60 lines

  1. #pragma once         /*prevents multiple inclusions of this file */
  2.  
  3. #include "CParticle.h"
  4. #include "FlockUtils.h" // handy vector and QuickDraw routines and stuff
  5.  
  6. #define kIDOffset 1000        // resource id offset to add to BoidType
  7.  
  8. /* The possible values for fScreenCtl */
  9. #define kDeepScr        1
  10. #define kBigScr            2
  11. #define    kAllScr            3
  12.     
  13. typedef struct
  14. {
  15.     // Average neighbor info
  16.     long        fNum;        // how many neighbors
  17.     FloatPoint    fAvgPos;
  18.     FloatPoint    fAvgVel;
  19.     double        fAvgDistSquared;
  20.     
  21.     // Nearest Neighbor info
  22.     FloatPoint    fNearestPos;
  23.     double        fNearestDistSquared;
  24. }NeighborRec;  // size = 34 bytes
  25.  
  26. class CBoid : CParticle
  27. {
  28. public:
  29.     NeighborRec    fNaybs; // CFlock sets this up each step
  30.     long        fCurrentFrame;    // The current frame of the animation: each boid needs its own
  31.     CBoid        *InitBoid(Rect *worldRect, Handle theBits, Handle theMaskBits, Point position);
  32.     
  33.     void        Move(    FloatPoint    *newPos,
  34.                         Rect         *worldRect,
  35.                         ControlRec     *controls,
  36.                         double         comfydistsq);
  37.     
  38.     void         GetBoidPos(FloatPoint *pos);
  39.     void         GetBoidVel(FloatPoint *vel);
  40.     
  41.     Boolean        HeadHome(void);
  42.     void        Nudge(void);
  43.     Boolean        fHome;
  44.  
  45. private:
  46.     Handle            fTheMap;
  47.     RgnHandle        fTheMaskRgn;
  48.     Ptr                fTheBits;
  49.     Point            fStartPoint;
  50.     
  51.     OSErr            InitBits(Handle theBits, Handle theMaskBits);
  52.     
  53.     
  54.     void        Reset(void);
  55.     void        NewAccel(double comfydistsq, ControlRec *controls);
  56.     void        RunAway(double comfydistsq, FloatPoint *request);
  57.     void        MatchVel(FloatPoint *request);
  58.     void        CatchUp(FloatPoint *request);
  59. };
  60.